<template>
  <div>
    <div class="checkbox">
      <input type="checkbox" />
    </div>
    {{ msg }}
    <test></test>
  </div>
</template>

<script>
import test from "./test.vue";
export default {
  components: {
    test,
  },
  data() {
    return {
      msg: "测试",
    };
  },
};
</script>

<style scoped>
.checkbox {
  --size: 100px;
}

.checkbox input[type="checkbox"] {
  -webkit-appearance: none;
  width: var(--size);
  height: calc(var(--size) / 2);
  background-color: #fff;
  border: 3px solid #222;
  border-radius: 30px 100px 100px 100px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  outline: none;
  cursor: pointer;
  position: relative;
  transition: all 0.5s;
}

.checkbox input[type="checkbox"]::before {
  content: "";
  position: absolute;
  width: calc(var(--size) / 2);
  height: calc(var(--size) / 2);
  left: 0;
  top: 50%;
  transform: translateY(-50%) scale(0.7);
  border: 3px solid #222;
  border-radius: 30px 100px 100px 100px;
  background-color: #fde881;
  box-sizing: border-box;
  transition: all 0.5s;
}

.checkbox input[type="checkbox"]:checked {
  background-color: #fde881;
  border-radius: 100px 100px 30px 100px;
}

.checkbox input[type="checkbox"]:checked::before {
  left: 50%;
  background-color: #fff;
  border-radius: 100px 100px 30px 100px;
}
</style>
